<template>
	<view>
		<view class="add-div">
			<view class="uni-padding-wrap uni-common-mt" style="margin-top:20px;">
				<button type="primary" @click="additem">新增</button>
				<!-- <button type="primary" style="margin-left: 10px;" size="mini">查询<uni-icons type="search" color="white" size="10"></uni-icons></button> -->
			</view>
			<!-- <view class="search">
				<view>
					<uni-search-bar placeholder="编号" :radius="100" v-model="parameter.no" bgColor="#EEEEEE" @input="search" />
				</view>
				
			</view> -->
			
		</view>
		        <view class="content">
						
						<view>
							<uni-list>
								<uni-swipe-action>
								<template v-for="(item,index) in houseList">
									
									 <uni-swipe-action-item :right-options="options" @click="onClick(item)">
										<uni-list-item  :title="item.title" :show-extra-icon="true" :extra-icon="message" showArrow :to="`./item?id=`+ item.id"/>
									</uni-swipe-action-item>
									
								</template>
								</uni-swipe-action>
							</uni-list>
						</view>
						<view class="line" style="clear:both"></view>

						<view>
							
						</view>
		            
		           
		        </view>
				 <view style='height: 100px;'></view>
	</view>
</template>

<script>
	import storage from '@/common/storage.js'
	import api from '@/common/api'
	export default {
	  data() {
	    return {
			parameter:{hid:0},
			project:{},
			message: {
				color: '#1890ff',
				size: '22',
				type: 'chatbubble'
			},
			houseList:[],
			options:[
			        {
			            text: '删除',
			            style: {
			                backgroundColor: '#dd524d'
			            }
			        }
			      ]
	    };
	  },
	  onLoad(option){
	  	this.project =this.$storage.getJson('project')
	  	this.parameter.hid = option.hid
	  	this.parameter.pid = option.pid
	  	this.getData()
	  },
	  onShow(){
		  if (this.$storage.getData('refresh')=='1') {
			  this.getData()
			  this.$storage.setData('refresh','')
		  }
	  },
	  onPullDownRefresh() {
		  
	  	this.getData();
	   setTimeout(function() {
	  		uni.stopPullDownRefresh();
	  	}, 1000);
	  },
	  methods: {
		  onClick(item){
			  var that = this
			  uni.showModal({
			          	title: '提示',
			          	content: '你确定要删除吗',
			          	success: function (res) {
			          		if (res.confirm) {
			          			that.Delete(item.id)
			          		} else if (res.cancel) {
			          			console.log('取消');
			          		}
			          	}
			          });
		  },
		  additem(){
			  uni.navigateTo({
			  	url: '../contact/item?id=0&pid='+this.parameter.pid+'&hid='+ this.parameter.hid
			  });
		  },
		  Delete(ids){
			  this.$request.postU(this.$api.CustomerContact.delete,{ids},'form').then(res=>{
				this.getData()
			  }); 
		  },
		  getData:function(){
			 this.$request.postU(this.$api.CustomerContact.list,this.parameter).then(res=>{
				 console.log('data',res.data)
			 	this.houseList = res.data
			 }); 
		  }
	  }
	};
</script>

<style>
	.add-div {
		position: fixed;
		bottom: 0px;
		font-size: 0;
		line-height: 0;
		z-index: 100;
		height: 80px;
		background: white;
	}
	.title{
		text-align: center;
		padding-top: 20px;
		padding-bottom: 20px;
		font-size: 20px;
	},
	.add-button{
		margin: 10px;
		/* margin-top: 10px;
		margin-bottom: 10px; */
	}
	.goods-box {
	    display: flex;
	    flex-wrap: wrap;
}
	    .imgList {
	      position: relative;
	      width: 220rpx;
	      height: 220rpx;
	          margin: 10rpx 20rpx 20rpx 10rpx;
	    }

	    .del {
	      position: absolute;
	      width: 60rpx;
	      height: 60rpx;
	      right: 1rpx;
		  top:7px;
	      z-index: 999;
	    }
</style>